//登录窗口，无边框
#pragma once

#include <QDialog>
#include "ui_logindialog.h"

QT_BEGIN_NAMESPACE
namespace Ui { class LoginDialogClass; };
QT_END_NAMESPACE

class LoginDialog : public QDialog
{
	Q_OBJECT

public:
	LoginDialog(QWidget *parent = nullptr);
	~LoginDialog();

private:
	Ui::LoginDialogClass *ui;

private:
	bool moving = false;
	
	QPoint leftPressPos;//记录鼠标左击事件窗口位置
	QPoint leftPressGloublePos;//记录鼠标左击事件全局位置

private:
	QString userName;//保存从注册表中读出的用户名
	QString password;//保存从注册表中读出的密码
	int tryCount = 0;
	int maxTryCount = 3;//最大尝试次数

	/**
	 * @brief 加密
	 * @param str 
	 * @return 
	*/
	QString encrypt(const QString& str);
	void readSettings();
	void writeSettings();

protected:
	virtual void mouseMoveEvent(QMouseEvent* event);
	virtual void mousePressEvent(QMouseEvent* event);
	virtual void mouseReleaseEvent(QMouseEvent* event);

public slots:
	void on_pushButton_OK_clicked();
};
